package com.david.apipassenger;

import com.david.apipassenger.annotation.ExcudeRibbonConfig;
import com.david.apipassenger.gray.GrayRibbonConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
@ComponentScan(
        excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION,value = ExcudeRibbonConfig.class)
        })
@RibbonClient(name="service-sms",configuration = GrayRibbonConfiguration.class)
public class ApiPassengerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ApiPassengerApplication.class,args);
    }


//    @Value("${zone.name}")
//    private String zoneName;
//
//    @GetMapping("/zoneName")
//    public String apiPassenger(){
//        return zoneName;
//    }



    @LoadBalanced
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    /**
     * 用来校验网关的
     * @return
     */
    @GetMapping("/test")
    public String test(){
        System.out.println("api-passenger-test");
        return "api-passenger";
    }


}
